/*************************************************************************
    > File Name: sleep1.c
    > Author: Xing.Dai
    > Mail: Xing.Dai@aliyun.com 
    > Created Time: 2017-05-24 22:47
 ************************************************************************/

#include <stdio.h>
#include <signal.h>
#include <unistd.h>

void wakeup(int signum)
{
	printf("Alarm received from kernel.\n");
}

int main()
{
	printf("about to sleep for 4 seconds.\n");

	signal(SIGALRM, wakeup);	/* catch it. */

	alarm(4);	/* set clock. */
	pause();	/* freeze here*/
	printf("Morning so soon? \n");
}
